/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mwt.xml.xdbforms.xformlayer;

import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;

/**
 * ErrorListener per la trasformazione del modello dati
 * in un documento xform
 * @author Gianfranco Murador, Cristian Castiglia, Matteo Ferri
 */
public class XFormErrorListener implements ErrorListener {

    private int nErrors,  nWarnings,  nFatals;


    /**
     * verifica l'esistenza di errori
     * @return true se ci sono stati errori, false altrimenti
     */
     public boolean hadProblems() {
        return (nErrors + nFatals > 0);
    }

    public XFormErrorListener() {

        reset();
    }



    public void reset() {
        nErrors = 0;
        nWarnings = 0;
        nFatals = 0;
    }

    public void warning(TransformerException exception) throws TransformerException {

           nWarnings++;
           exception.printStackTrace();
     
    }

    public void error(TransformerException exception) throws TransformerException {
           nErrors++;
          exception.printStackTrace();

    }

    public void fatalError(TransformerException exception) throws TransformerException {

          nFatals++;

          throw exception;
      


    }
}
